﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.Items.Add("福建省");
                DropDownList1.Items.Add("浙江省");
                DropDownList1.Items.Add("江苏省");
                DropDownList2.Items.Add("莆田市");
                DropDownList2.Items.Add("龙岩市");
                DropDownList2.Items.Add("厦门市");
            }
            if (FileUpload1.HasFile)
            {
                string fileName = FileUpload1.FileName;
                if (fileName.EndsWith(".jpg") || fileName.EndsWith(".jpeg"))
                {
                    string path = Server.MapPath(@"~\img\" + fileName);
                    FileUpload1.SaveAs(path);
                    Image1.Visible = true;
                    Image1.ImageUrl = "~/img/" + fileName;
                }
                else
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "提示", "alert('图片格式不正确')", true);
                }
            }
            //else
            //{
            //    this.ClientScript.RegisterStartupScript(this.GetType(), "提示", "alert('请提供上传文件')", true);
            //}
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string po = DropDownList1.SelectedValue;
            DropDownList2.Items.Clear();
            if (po == "福建省")
            {
                DropDownList2.Items.Add("莆田市");
                DropDownList2.Items.Add("龙岩市");
                DropDownList2.Items.Add("厦门市");
            }
            else if (po == "浙江省")
            {
                DropDownList2.Items.Add("金华市");
                DropDownList2.Items.Add("海宁市");
                DropDownList2.Items.Add("义乌市");
            }
            else
            {
                DropDownList2.Items.Add("连云港");
                DropDownList2.Items.Add("不知市");
                DropDownList2.Items.Add("知道市");
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label8.Text = "用户名：" + TextBox1.Text + "\t性别：" + RadioButtonList1.SelectedValue + "\t爱好：" + TextBox3.Text + "\t籍贯：" + DropDownList1.SelectedValue + "；" + DropDownList2.SelectedValue + "\t其它信息：" + TextBox4.Text;
        }
    }
}